﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ChicagoDealsN;
using System.Data.SqlClient;
using System.Data;



namespace ChicagoDealsN
{
    public class BizUser
    {

        public bool BL_IsExists(string email)
        {
            DataUser du = new DataUser();
            bool c = du.IsExists(email);
            return c;
        }

        public static DataUser Login(string userName, string passWord)
        {
           
            DataUser loginUser = new DataUser(userName);
            loginUser.Load();
            if (loginUser != null && loginUser.Password.Equals(passWord))
            {
                return loginUser;
            }
            return null;
        }
        public Boolean BLUpdateAccount(int _user_Id, string _password, string _username, string _address, string _email, string _cc_Payment, char _gender)
        {
            DataUser du = new DataUser();
            return du.DLUpdateAccount(_user_Id,_password,_username,_address, _email, _cc_Payment,_gender);
        }

        public Boolean BLCreateAccount(string _username, string _password, string _address, string _email, string _cc_Payment, char _gender, string _state, int _isVendor)
        {
             DataUser du1 = new DataUser();
             try {
                 if (!BL_IsExists(_email))
                 {
                     int _points = 1000;
                     bool b = du1.DLCreateAccount(_username, _password, _address, _email, _cc_Payment, _gender, _points, _state, _isVendor);
                     return b;
                 }
                 else
                     return false;
		      }
		      catch (Exception expException)  //what is the matter?

                  
		        {throw expException;}
        }

    }
}